<template>
  <div ref="energyConsumption3" style="width: 100%; height: 380px"></div>
</template>

<script>
import * as echarts from "echarts";
import { zhuShow2 } from "@/api/charts";

export default {
  mounted() {
    this.drawline();
  },
  methods: {
    drawline() {
      zhuShow2()
        .then(({ data }) => {
          var chartDom = this.$refs.energyConsumption3;
          var myChart = echarts.init(chartDom);
          var option;

          option = {
            title: {
              text: "消耗量折线图",
            },
            xAxis: {
              type: "category",
              data: data.name,////***************** */
            },
            yAxis: {
              type: "value",
            },
            series: [
              {
                data: data.value, ////************ */
                type: "line",
              },
            ],
          };

          option && myChart.setOption(option);
        })
        .catch((err) => {});
    },
  },
};
</script>

<style>
</style>